package client_gui;

import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JToolBar;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

import actions.RLMActionManager;

/**
 * Panel sa precicama komandi. Klasa prosiruje JToolBar, sto omogucava da se u
 * ovaj panel dodaju Action objekti, koji predstavljaju akcije GUI komponenti.
 * 
 * @author UrosKrkic & Radivoje Popovic
 */
public class ShortcutPanel extends JToolBar {

	/**
	 * Vlasnik - glavni prozor aplikacije.
	 */
	private ClientWindow owner;

	/**
	 * Indikator da li je ToolBar floatable.
	 * Default: false.
	 */
	private boolean floatable = false;
	
	
	/**
	 * Referenca na actionManager.
	 */
	private RLMActionManager actionManager;
	
	
	/**
	 * Border komponente.
	 */
	private TitledBorder titledBorder;
	
	
	/**
	 * Boja panela.
	 */
	private Color panelColor = new Color(125,144,124);

	
	
	/**
	 * Konstruktor.
	 * @param owner - glavni prozor aplikacije
	 * @author UrosKrkic & Radivoje Popovic
	 */
	public ShortcutPanel(ClientWindow owner) {
		super();
		this.owner = owner;
		
		this.actionManager = this.owner.getActionManager();

		titledBorder = BorderFactory.createTitledBorder(BorderFactory.
				createEtchedBorder(EtchedBorder.RAISED),
				"Shortcuts", javax.swing.border.TitledBorder.CENTER,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				null, null);
		
	
		initializeShortcutPanel();
	}


	/**
	 * Metod vrsi inicijalizaciju ovog panela.
	 * @author UrosKrkic & Radivoje Popovic
	 */
	private void initializeShortcutPanel() {
		this.setLayout(new FlowLayout(FlowLayout.CENTER));
		this.setFloatable(floatable);
		this.setBorder(titledBorder);

		this.setBackground(panelColor);
		
		// dodavanje akcija (dugmadi)
		this.add(actionManager.getFindUserAction());
		this.addSeparator();
		this.add(actionManager.getBlockListAction());
		this.addSeparator();
		this.add(actionManager.getOptionsAction());
		this.addSeparator();
		this.add(actionManager.getLogoutAction());
		this.addSeparator();
		this.add(actionManager.getHelpAction());
	}

}
